package com.example.mobile2121606109ycg0524homework1;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class MySQLiteOpenHelper extends SQLiteOpenHelper {
    public MySQLiteOpenHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql = "create table staff(_id integer primary key autoincrement, name varchar(20) not null, skill varchar(20), salary varchar(20))";
        db.execSQL(sql);

        ContentValues values = new ContentValues();
        values.put("name","李刚");
        values.put("skill","汽车工程师");
        values.put("salary","200");
        db.insert("staff", null, values);
        values.put("name","丁运生");
        values.put("skill","汽车工人");
        values.put("salary","50");
        db.insert("staff", null, values);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
